﻿package core.ui.controls
{
    import flash.display.*;
    import flash.events.*;

    public class IconButton extends Sprite
    {
        private var over:Bitmap;
        private var out:Bitmap;
        private var ed:Tuyitu;

        public function IconButton(param1:Tuyitu, param2:String, param3:BitmapData)
        {
            this.ed = param1;
            this.name = param2;
            this.over = new Bitmap(param3);
            this.out = new Bitmap(param3.clone());
            UI.Desaturate(this.out.bitmapData);
            this.over.visible = false;
            addChild(this.out);
            addChild(this.over);
            this.addEventListener(MouseEvent.MOUSE_OVER, this.MouseOver, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_OUT, this.MouseOut, false, 0, true);
            return;
        }// end function

        private function MouseOver(event:MouseEvent) : void
        {
            this.out.visible = false;
            this.over.visible = true;
            if (this.ed != null)
            {
                this.ed.hover.Set(name);
            }
            return;
        }// end function

        private function MouseOut(event:MouseEvent) : void
        {
            this.out.visible = true;
            this.over.visible = false;
            if (this.ed != null)
            {
                this.ed.hover.Hide();
            }
            return;
        }// end function

    }
}
